"""
time operation.
date：2020/06/26
"""
import time
import datetime


class MyDate:
    def __init__(self):
        self.current_timestamp = int(time.time())
        self.current_datetime = datetime.datetime.today()
        # notation_time convert the secends.
        self.notation_time = {
            'h': 3600,
            'm': 60,
            's': 1
        }

    def month(self):
        return self.current_datetime.month

    def day(self):
        return self.current_datetime.day

    def __sub__(self, other):
        """
        sub operation, attach time notation.
        hour is h, munite is m, secend is s.
        :param other: such as '1h', '2m'.
        :return: the difference between the time.
        """
        hour = other[0:-1]
        notation = other[-1:]
        return self.current_timestamp - int(hour) * self.notation_time[notation]


if __name__ == '__main__':
    mydata = MyDate()
    print(mydata - '1h')
    print(mydata - '24m')
    # d = datetime.datetime(year=2020, month=7, day=3, hour=12, minute=0, second=0)
    d = datetime.datetime.today()
    print(d.timestamp())